package com.example.pingtools.base

import android.app.AlertDialog
import android.content.Context
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.WindowManager
import com.example.mygreendao.GreenDaoManager
import com.example.pingtools.R
import com.example.pingtools.util.PingUtil
import kotlinx.android.synthetic.main.layout_addip.*
import kotlinx.android.synthetic.main.layout_addip.tv_cancle
import kotlinx.android.synthetic.main.layout_addip.view.*
import kotlinx.android.synthetic.main.layout_addip.view.tv_cancle
import kotlinx.android.synthetic.main.lyout_addwj.*
import kotlinx.android.synthetic.main.lyout_addwj.view.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import java.lang.Exception
import java.net.ConnectException
import java.net.InetSocketAddress
import java.net.Socket

class dialogwj(context: Context) : AlertDialog(context),
    View.OnClickListener {



    init {
        var layout = LayoutInflater.from(context).inflate(R.layout.lyout_addwj, null)

        setView(layout)

        //设置点击别的区域关闭页面
        setCancelable(true)

        layout.tv_qr.setOnClickListener(this)
        layout.tv_cancle.setOnClickListener(this)
    }

    override fun show() {
        val params: WindowManager.LayoutParams = window!!.attributes
        params.width = 700
        params.gravity = Gravity.CENTER
        window!!.attributes = params
        window!!.setBackgroundDrawableResource(android.R.color.transparent)

        super.show()
    }

    override fun onClick(v: View?) {
        when (v) {
           tv_qr ->{
               dismiss()
            }
            tv_cancle -> {
                dismiss()
            }
        }

    }



}